//


#import "NT_WaitTableViewCell.h"

@implementation NT_WaitTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //
        self.titleLabel =  ({
            UILabel *label = [[UILabel alloc]init];
            label.textColor = rgba(90, 90, 90, 1);
            label.font = FontPFRegular(kRelativeWidth(16));
            label.text = @"";
            [self.contentView addSubview:label];
            label;
        });
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.left.mas_offset(kRelativeWidth(20));
            make.right.mas_offset(-kRelativeWidth(50));
            make.height.mas_equalTo(kRelativeHeight(20));
        }];
        
        self.deleteBtn =  ({
            UIButton *button = [[UIButton alloc]init];
            [button setImage:[UIImage imageNamed:@"ic_choose_nor"] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"ic_choose_select"] forState:UIControlStateSelected];
            [button addTarget:self action:@selector(Action:) forControlEvents:UIControlEventTouchUpInside];
            button.hidden = YES;
            [self.contentView addSubview:button];
            button;
        });
        [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.titleLabel);
            make.right.mas_offset(-kRelativeWidth(20));
            make.width.height.mas_equalTo(kRelativeWidth(30));
        }];
        
    }
    return self;
}
//
- (void)Action:(UIButton*)btn {
    //    btn.selected =! btn.selected;
    if ([self.delegate respondsToSelector:@selector(sendCell:)]) {
        [self.delegate sendCell:self];
    }
}

//
- (void)setModel:(WaitData *)model {
    _model = model ;
    //
    self.titleLabel.text = model.title;
    if (model.status == 1 ) {
        self.deleteBtn.selected = YES;
    }else
        self.deleteBtn.selected = NO;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
